{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "a30b0bc1",
   "metadata": {},
   "source": [
    "* 函数是命名的代码块\n",
    "* def关键字用来命名函数，函数代码在def关键字下（相对于def关键字）缩进\n",
    "* python的三重引号字符串可以用来为函数增加多行注释。如果采用这种方式，它称为docstring\n",
    "* 函数可以接受任意多个命名参数，也可以没有参数\n",
    "* return语句允许函数返回任意多个值（也可以不返回任何值）\n",
    "* 函数注解可以用来描述函数参数的类型以及函数的返回类型"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "40836b84",
   "metadata": {},
   "source": [
    "# 函数可以接收参数\n",
    "* 不需要让函数提示用户输入一个要搜索的关键词，可以传入单词作为一个参数的输入  \n",
    "* 增加参数：把参数名插入到def行上的小括号中间，参数名将成为函数代码组中的一个变量。  "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "af6c498e",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 原函数\n",
    "def search4vowels():\n",
    "    \"\"\"Display any vowels found in an asked-for word.\"\"\"\n",
    "    vowels = set('aeiou')\n",
    "    word = input('Provide a word to search for vowels: ')\n",
    "    found = vowels.intersection(set(word))\n",
    "    for vowel in found:\n",
    "        print(vowel)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "d2d25f90",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 需要删掉input\n",
    "def search4vowels(word): # 参数名放在小括号间，不再有“input”调用函数\n",
    "    \"\"\"Display any vowels found in an asked-for word.\"\"\"\n",
    "    vowels = set('aeiou')\n",
    "    found = vowels.intersection(set(word))\n",
    "    for vowel in found:\n",
    "        print(vowel)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "eab541fe",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.8"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {},
   "toc_section_display": true,
   "toc_window_display": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
